/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlrpc.server;

import java.io.File;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.ServletWebServer;
import org.apache.xmlrpc.webserver.WebServer;
import org.apache.xmlrpc.webserver.XmlRpcServlet;
import org.apache.xmlrpc.webserver.XmlRpcServletServer;

/**
 *
 * @author martin
 */
public class Calculate_servlet extends XmlRpcServlet{

  @Override
  protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException{
    PropertyHandlerMapping phm = new PropertyHandlerMapping();
    phm.addHandler("sample", Calculate.class);
    return phm;
  }
  public static void main(String[]args) throws LifecycleException, XmlRpcException, ServletException{
    Tomcat tomcat = new Tomcat();
    tomcat.setPort(8088);
    Context ctx = tomcat.addContext("/", new File(".").getAbsolutePath());
 
    Servlet servlet = new Calculate_servlet();

    Tomcat.addServlet(ctx, "hello", servlet);
    ctx.addServletMapping("/", "hello");
    tomcat.start();
    tomcat.getServer().await();
  }
}
